<template>
    <div class="commissionSet-view">
        <el-dialog :title="titleText" :visible.sync="dialogFormVisible" width="10%" :show-close="showimg">
            <div>
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                    <div class="commissionSet-view-title">佣金规则：</div>
                    <el-form-item prop="divisionRules">
                        <div>
                            <el-input
                                    type="textarea"
                                    :autosize="{ minRows: 4, maxRows: 6}"
                                    placeholder="输入佣金规则"
                                    v-model="ruleForm.divisionRules">
                            </el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="启用状态:" prop="useSts">
                        <el-radio-group v-model="ruleForm.useSts">
                            <el-radio label="1">启用</el-radio>
                            <el-radio label="0">禁用</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item  label="到期时间："  required>
                        <el-col :span="11">
                            <el-form-item prop="date1">
                                <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.outTime" style="width: 100%;"></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-form-item>
                </el-form>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button class="cancel-button"  @click="closeForm" >取 消</el-button>
                <el-button class="sure-button" type="primary" @click="addstruct('ruleForm')">保 存</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "commissionSet",
        data(){
            return{
                organizationId: this.$store.getters.userData.userMsg.id,//组织id
                titleText:"佣金设置",
                showimg:false,
                ruleForm:{
                    linkerIds:"",
                    distributorId:this.$store.getters.userData.userMsg.id,//组织id
                    divisionRules:"",
                    useSts:"0",
                    outTime:"",
                },
                rules: {
                    divisionRules:[
                        { required: true, message: '请输入佣金规则', trigger: 'blur' },
                    ],
                    useSts:[
                        { required: true, message: '请输选择资源', trigger: 'blur' },
                    ],
                    outTime:[
                        { required: true, message: '请输选择时间', trigger: 'blur' },
                    ]
                }
            }
        },
        props:{
            dialogFormVisible: {
                type: Boolean
            },
            linkerIdString:{
                type: String
            },
        },
        watch: {
            linkerIdString:{
                handler(newValue, oldValue) {
                    this.ruleForm.linkerIds=newValue
                }
            }
            },
        methods: {
            closeForm() {
                console.log("aaaaaaa")
                this.$emit("close");
            },
            addstruct(formname){
                let _this = this;
                this.$refs[formname].validate((valid) => {
                    if (valid) {
                        _this.Api.setting.distSetAllHouseCommission(this.ruleForm).then((data)=>{
                            console.log("成功",data)
                            this.$emit("refreshList");
                            this.closeForm()
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            getlist(){
                let _this = this;
                let params={
                    distributorId:this.organizationId,
                }
                console.log("pppppppppppppppppppp",params)
                _this.Api.setting.queryResidentList(params).then((data)=>{
                    console.log("aaaaaaaaaaaaaaa",data)
                    _this.totalpag=data.data.total;
                    _this.list=data.data.records;
                })
            }
        }
    }
</script>
<style>
    .commissionSet-view  .el-form-item__label{
        min-width: 80px!important;
        text-align: left;
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(0,0,0,1);
        padding: 11px 0px 11px 0px;
    }
    .commissionSet-view .el-radio{
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(0,0,0,0.65);
    }
</style>
<style scoped rel="stylesheet/scss" lang="scss">
.commissionSet-view{
    .commissionSet-view-title{
        font-size:14px;
        font-family:PingFangSC-Regular;
        font-weight:400;
        color:rgba(0,0,0,1);
        margin-bottom: 8px;
    }
}
</style>